package com.ks.core.framework.cpsupload.demos.orderpayinvoice.paytemplate;

import com.ks.core.framework.cpsupload.demos.orderpayinvoice.constant.OrderType;
import com.ks.core.framework.cpsupload.demos.orderpayinvoice.constant.PaymentType;
import com.ks.core.framework.cpsupload.demos.orderpayinvoice.orderhandler.ConferenceOrder;
import com.ks.core.framework.cpsupload.demos.orderpayinvoice.orderhandler.Order;

import java.math.BigDecimal;

// 注册费支付流程实现
public class ConferencePaymentProcessor extends PaymentTemplate {
    @Override
    protected boolean validate(Order order, PaymentType type, BigDecimal amount) {
        // 验证订单类型是否正确
        if (order.getOrderType() != OrderType.CONF_REGISTRATION) {
            return false;
        }
        
        // 验证套餐是否有效
        if (!isPackageValid(((ConferenceOrder) order).getPackageId())) {
            return false;
        }
        
        // 金额验证
        return amount.compareTo(BigDecimal.ZERO) > 0;
    }
    
    @Override
    protected void postProcess(Order order, PaymentType type, BigDecimal amount, boolean success) {
        if (success) {
            // 添加支付记录
            order.addPaymentRecord(type, amount, generateTransactionId());
        } else {
            // 记录支付失败
            PaymentFailureService.recordFailure(order, type, amount);
        }
    }
    
    // 其他辅助方法...
}